package test.persistent;

import test.WorkFlowTest;

import com.cait.framework.data.DevidePageParms;
import com.cait.workflowserver.definition.activitydefiniton.Activity;
import com.cait.workflowserver.definition.processdefinition.ProcessCategory;
import com.cait.workflowserver.definition.transitiondefiniton.Transition;
import com.cait.workflowserver.execution.execinstance.AbstractActivityInstance;
import com.cait.workflowserver.execution.execinstance.AutomationActivityInstance;
import com.cait.workflowserver.execution.execinstance.FlowInstanceCollection;
import com.cait.workflowserver.execution.execinstance.ProccessInstanceCollection;
import com.cait.workflowserver.execution.execinstance.ProcessInstance;
import com.cait.workflowserver.execution.execinstance.TransitionInstance;
import com.cait.workflowserver.execution.execinstance.enInstanceState;
import com.cait.workflowserver.persistent.ProcessInstanceManager;
import com.cait.workflowserver.persistent.DataProvider.oracledataprovider.OracleFlowCoreDataProvider;
import com.cait.workflowserver.runtime.Server;

public class testActInst extends WorkFlowTest {
	public testActInst(String arg0)
	{
		super(arg0);
		
	}
	
	public void testInsertClass()
	{
		Server.getInstance().startService();
		OracleFlowCoreDataProvider op=new OracleFlowCoreDataProvider();
		//AutomationActivityInstance at=new AutomationActivityInstance();
		//at.setProcInstId("4a30e61d-79c8-4968-97fb-714ffcbeec20");
		//at.setName("测试");
		//at.setActivityId("dsd3-423423e334");
		//at.setRout(true);
		System.out.println("workitem:"+op.getWorkItem("4494dd18-6af5-467f-8bca-b83230494863").getId()+op.getWorkItem("4494dd18-6af5-467f-8bca-b83230494863").getName());
		DevidePageParms d=new DevidePageParms();
		
		
		System.out.println("workitem:"+op.getWorkItemList(null, null, null, null, null, enInstanceState.ACTIVEING,d));
		System.out.println("workcount:"+d.recordCount);
		System.out.println("procInsd:"+op.getProcessInstance("7ba9bd00-2940-4d4e-aefe-9795962c8820").getId());
		System.out.println("procName"+op.getProcessHeader(null).getId()+op.getProcessHeader(null).getName());
		//op.getWorkItemList(categoryId, processId, procInstId, ownerId, type, state, pageParms)
		//4a30e61d-79c8-4968-97fb-714ffcbeec20
		 //ProcessInstance pi=new ProcessInstance("dsd3-423423e334");
		// pi.setId(Guid.getGuid());
		// pi.setName("测试");
		// pi.setState( enInstanceState.values()[4]);
		// op.insertActivityInstance(at);
		// Server.getInstance().stop();
//		OracleDataProvider op=new OracleDataProvider();
//		ProccessInstanceCollection pic=op.getProcessInstanceListByCreator(null,null,new DevidePageParms(0,0));
//		ProcessInstanceManager pim=new ProcessInstanceManager();
//		System.out.println(pic.size());
//		for(int i=0;i<pic.size();i++)
//		{
//			System.out.println("家寨1");
//			ProcessInstance p=(ProcessInstance)pic.get(i);
//			try
//			{
//				p= pim.loadProcessInstance(p.getId(),null);
//			}catch(Exception ex)
//			{
//				continue;
//				
//			}
//			if(p==null)
//				continue;
//			//System.out.println(p.getTranInsts().size());
//			try
//			{
//				System.out.println(p.getTranInsts().size());
//				
//				 
//			for(int j=0;j<p.getTranInsts().size();j++)
//			{
//				System.out.println("家寨");
//				TransitionInstance ti=(TransitionInstance)p.getTranInsts().get(j);
//				if(ti==null)
//					continue;
//				String ai=ti.getFormActInstId();
//				AbstractActivityInstance aa=p.getActInsts().get(ai);
//				AbstractActivityInstance at =p.getActInsts().get(ti.getToActInstId());
//				if(aa==null)
//					continue;
//				if(at==null)
//					continue;
//				
//				Activity act=aa.findEnabledActDef();
//				Activity act2=at.findEnabledActDef();
//				if(act==null)
//					continue;
//				if(act2==null)
//					continue;
//				
//				//act2.
//				for(int k=0;k<act.getToTransitions().size();k++)
//				{
//					Transition t=(Transition)act.getToTransitions().get(k);
//					//act2.
//				 	if(t.getToActId().equals(act2.getId()))
//				 	{
//				 		ti.setTranDefId(t.getId() );
//				 		op.updateTransitionInstance(ti);
//				 		System.out.println(t.getId());
//				 		break;
//				 	}
//			 
//					
//				}
//			}
//			}catch(Exception ex)
//			{
//				continue;
//				
//			}
//		}
//		
//		System.out.println("完成...");
		
		
	}
}
